package com.starbugs.wehcat.pojo;

import lombok.Data;

import javax.validation.constraints.Digits;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

// 所有校验注解的message属性定义了当输入的信息不满足声明的校验规

// @Table
// - name 用来命名 当前实体类 对应的数据库 表的名字
// - uniqueConstraints 批量命名唯一键 @Table(name = "tab_user",uniqueConstraints = {@UniqueConstraint(columnNames={"uid","email"})})

// !!! order是SQL的保留字

/**
 * @author huahuadavids
 */
@Data
public class Order {

  private long id;

  private Date placedAt;

  private Date createAt;

  @NotBlank(message="Name is required")
  private String name;


  @NotBlank(message="Street is required")
  private String street;


  @NotBlank(message="City is required")
  private String city;


  @NotBlank(message="State is required")
  private String state;


  @NotBlank(message="Zip code is required")
  private String zip;


  // @CreditCardNumber(message="Not a valid credit card number")

  @Digits(integer=8, fraction=0, message="Invalid ccNumber")
  private String ccNumber;


  @Pattern(regexp="^(0[1-9]|1[0-2])([\\/])([1-9][0-9])$",message="Must be formatted MM/YY")
  private String ccExpiration;


  @Digits(integer=3, fraction=0, message="Invalid CVV")
  private String ccCVV;

  private List<Taco> tacos = new ArrayList<>();

  public void addDesign(Taco design) {
    this.tacos.add(design);
  }


}
